laetitia=# create table test(id integer generated always as identity);
CREATE TABLE
laetitia=# table test;
id
----
(0 rows)
laetitia=# begin;
BEGIN
laetitia=*# drop table test;
DROP TABLE
laetitia=*# table test;
2024-04-11 13:05:20.589 CEST [18422] ERROR: relation "test" does not exist at character 7
2024-04-11 13:05:20.589 CEST [18422] STATEMENT: table test;
ERROR: relation "test" does not exist
LINE 1: table test;
^
laetitia=!# rollback;
ROLLBACK
laetitia=# table test;
id
----
(0 rows)
COMMENT ON LANGUAGE plpython IS 'Python support for stored procedures';
COMMENT ON OPERATOR - (NONE, integer) IS 'Unary minus';
COMMENT ON DATABASE my_database IS 'Development Database';
COMMENT ON ROLE my_role IS 'Administration group for finance tables';
Access ALL YOUR DATA (really, all your data, we are not joking) from EVERYWHERE to Postgres!
$$Dianne's horse$$
$SomeTag$Dianne's horse$SomeTag$
string SIMILAR TO pattern [ESCAPE escape-character]
string NOT SIMILAR TO pattern [ESCAPE escape-character]
'thomas' ~ 't.*ma' → t
'thomas' ~ 't.*ma' → t
'thomas' !~ 't.*max' → t
'thomas' !~* 'T.*ma' → f
regexp_count | regexp_replace |
regexp_instr | regexp_replace |
regexp_like | regexp_split_to_array |
regexp_match | regexp_split_to_table |
regexp_matches |
regexp_substr |
SELECT '"foo"'::jsonb @> '"foo"'::jsonb;
SELECT '[1, 2, 3]'::jsonb @> '[1, 3]'::jsonb;
SELECT '[1, 2, 3]'::jsonb @> '[3, 1]'::jsonb;
SELECT doc->'site_name' FROM websites
WHERE doc @> '{"tags":[{"term":"paris"}, {"term":"food"}]}';
$.track.segments
: retrieves the
available track segments$.track.segments[*].location
: retrieves
the contents of an array$.track.segments[1].location
: returns
the coordinates of the first segment only? (condition)
: filtersselect name,
medium_hval,
location
from interesting_cities
where (
select ST_Distance (
ST_Transform (location, 3587),
ST_Transform( (
select location
from interesting_cities
where name = 'Boston'), 3587)
) ) < 150000
order by medium_hval
limit 10;
WITH upd AS (
UPDATE employees SET sales_count = sales_count + 1 WHERE id =
(SELECT sales_person FROM accounts WHERE name = 'Acme Corporation')
RETURNING *
)
INSERT INTO employees_log SELECT *, current_timestamp FROM upd;
INSERT INTO distributors (did, dname)
VALUES (5, 'Gizmo Transglobal'), (6, 'Associated Computing, Inc')
ON CONFLICT (did) DO UPDATE SET dname = EXCLUDED.dname;
MERGE INTO wines w
USING wine_stock_changes s
ON s.winename = w.winename
WHEN NOT MATCHED AND s.stock_delta > 0 THEN
INSERT VALUES(s.winename, s.stock_delta)
WHEN MATCHED AND w.stock + s.stock_delta > 0 THEN
UPDATE SET stock = w.stock + s.stock_delta
WHEN MATCHED THEN
DELETE;